package com.moyu.admin.bean;

import java.util.List;
import lombok.Data;
import lombok.ToString;

/**
 * 权限节点树(BootStrap-TreeView) 源码不包含主键id，修改源码：line522 line267 参考:
 * https://blog.csdn.net/irene1991/article/details/79624477
 */
@Data
@ToString
public class TreeNodePerm {

  // 物理主键
  private Long pkId;
  // 列表树节点上的文本
  private String text;
  // 列表树节点上的图标
 /* private String icon;
  */
  private TreeState state;

  private List<TreeNodePerm> nodes;

  public TreeNodePerm(Long pkId, String text) {
    this.pkId = pkId;
    this.text = text;
  }

  public void setChecked(){
    this.setState(new TreeState(true,true));
  }
  @Data
  @ToString
  static class TreeState {
    // 是否被选中
    private boolean checked;
    // 是否disable
    private boolean disabled;
    // 是否展开
    private boolean expanded;
    // 是否可选
    private boolean selected;

    public TreeState(boolean checked, boolean expanded) {
      this.checked = checked;
      this.expanded = expanded;
    }
  }
}
